﻿using AwesomeChromeFormUI.Attributes;
using AwesomeChromeFormUI.Configs;
using AwesomeChromeFormUI.Reflections;
using System;
using System.Reflection;

namespace AwesomeChromeFormUI.Interfaces.Configs
{
    /// <summary>
    /// 默认实现
    /// </summary>
    public class DefaultICefConfiger
    {
        public static CefConfiguration CreateCustomCefConfiguration()
        {
            Type type = AttributeUtil.FindFirstAnnotatedClass<CefConfigurationAttribute, ICefConfiger>();

            if (type != null)
            {
                ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);

                if (constructor != null)
                {
                    ICefConfiger cefConfiger = constructor.Invoke(null) as ICefConfiger;
                    return cefConfiger.CreateCustomCefConfiguration();
                }
            }

            return new CefConfiguration();
        }
    }
}
